/**
 * This class represents a node within a skiplist.
 * @author Matt version 1.0
 *
 * @param <T>
 */
public class SkipListNode<T extends Comparable<T>> implements Comparable<SkipListNode<T>> {

	private SkipListNode<T> up,down,next,previous;
	private T data;
	
	public SkipListNode(T data)
	{
		this.data = data;
		up = null;
		down = null;
		next = null;
		previous = null;
	}

	/**
	 * This will return the value of the comparison of data help within two nodes.
	 * @return int
	 */
	@Override
	public int compareTo(SkipListNode<T> node) 
	{
		return this.data.compareTo(node.data);
	}
	/**
	 * This will return whether or not two nodes are equal based
	 * upon their data
	 * 
	 * @return boolean
	 */
	@Override
	public boolean equals(Object node)
	{
		@SuppressWarnings("unchecked")
		int compare = this.compareTo((SkipListNode<T>)node);
		return compare==0;
	}
	
	/**
	 * This return the string version of the data being contained.
	 * 
	 * 
	 * @return the data as a string
	 */
	@Override
	public String toString()
	{
		return this.data.toString();
	}
	/**
	 * This will return the data contained in a node
	 * 
	 * @return Data in a node
	 */
	public T getData()
	{
		return data;
	}
	/**
	 * Sets the data in a node to the passed in data
	 * @param dataIn
	 */
	public void setData(T dataIn)
	{
		this.data = dataIn;
	}
	/**
	 * Sets the next value of a node to the passed in node
	 * @param node New node
	 */
	public void setNext(SkipListNode<T> node)
	{
		this.next = node;
	}
	/**
	 * Sets the up value of a node to the passed in node.
	 * @param node New Node
	 */
	public void setUp(SkipListNode<T> node)
	{
		this.up = node;
	}
	/**
	 * Sets the down value of the current node to the passed in node
	 * @param node New node
	 */
	public void setDown(SkipListNode<T> node)
	{
		this.down = node;
	}
	/**
	 * Sets the previous value of the current node to the passed in node
	 * @param node New node
	 */
	public void setPrevious(SkipListNode<T> node)
	{
		this.previous = node;
	}
	/**
	 * Returns the node held in the next variable
	 * @return Next node
	 */
	public SkipListNode<T> getNext()
	{
		return next;
	}
	/**
	 * Returns the node in the up variable.
	 * @return Up node
	 */
	public SkipListNode<T> getUp()
	{
		return up;
	}
	/**
	 * Returns the node in the down variable
	 * @return Down node
	 */
	public SkipListNode<T> getDown()
	{
		return down;
	}
	/**
	 * Returns the previous node
	 * @return Previous node
	 */
	public SkipListNode<T> getPrevious()
	{
		return previous;
	}
	

}
